import axios, { type AxiosRequestConfig, type AxiosResponse } from 'axios'

const req = axios.create({
  baseURL: process.env.VUE_APP_API_PREFIX,
})

req.interceptors.request.use(
  (config) => {
    Object.assign(config.headers, {})

    return config
  },
  (error) => {
    return Promise.reject(error)
  },
)

req.interceptors.response.use(
  (res: AxiosResponse) => {
    return res.data
  },
  (err) => {
    return Promise.reject(err)
  },
)

export default req
